import React from 'react';
import { Table } from 'antd';
import PropTypes from 'prop-types';
import styles from './index.less';
import { tableLocale } from '@/tool/components/PageEmpty';

const useTable = (props) => {
  const { owncolumns, loading, baseProps, dataSource, type } = props;
  const yScroll = type == 'Management' && { y: 516 };
  return (
    <div className={styles.tableWrap}>
      <Table
        columns={owncolumns()}
        pagination={false}
        dataSource={dataSource}
        loading={loading}
        {...baseProps}
        rowClassName={(record) => {
          return record.indentation ? styles.expandRowStyle : '';
        }}
        locale={tableLocale}
        scroll={{ x: 1100, ...yScroll }}
        bordered={true}
        style={{ width: '100%', height: '100%', fontSize: '12px' }}
      />
    </div>
  );
};

useTable.propTypes = {
  owncolumns: PropTypes.func,
  loading: PropTypes.bool,
  baseProps: PropTypes.object,
  dataSource: PropTypes.array,
  type: PropTypes.string,
};

export default useTable;
